﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Film.Repository;
using Ext.Net;

namespace PhuongDoAn.Admin.User
{
    public partial class Detail : AdminWebBase
    {
        public int ID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            ////tinh thang ID dua tren query tim duoc!
            if (Request.QueryString["ItemID"] != null)
            {
                int.TryParse(Request.QueryString["ItemID"].ToString(), out ID);
            }

            if (!IsPostBack && !X.IsAjaxRequest)
            {
                try
                {
                    InitLoadAction();
                }
                catch (Exception ex)
                {
                    THONG_BAO_CAP_NHAT("Lỗi : " + ex.Message );
                }
            }
        }

        private void InitLoadAction()
        {
            ////thuc hien tim van ban o day va thuc hien
            tblUserAccountRepository acountRepository = new tblUserAccountRepository();
            tblUserAccount entity = acountRepository.Get(ID);
            if (entity == null || (entity != null && entity.IsAdmin != false))
            {
                //Dong lai cai form nay luon
                Page.Response.Redirect(ConfigKey.ERROR_URL);
                return;
            }
            ltUserName.Html= HttpUtility.HtmlEncode(entity.UserName);
           ltFullName.Html = HttpUtility.HtmlEncode(entity.FullName);
            ltEmail.Html = HttpUtility.HtmlEncode(entity.Email);
           // ltAge.Html = entity.tblUser.a
            if (entity.tblUser != null)
            {
                if (entity.tblUser.tblAge != null)
                {
                    ltAge.Html =  HttpUtility.HtmlEncode(entity.tblUser.tblAge.AgeName);
                }
                if (entity.tblUser.tblOccupation != null)
                {
                    ltOccupation.Html = HttpUtility.HtmlEncode(entity.tblUser.tblOccupation.OccupationName);
                }
            }

        }
    }
}